package com.drakulo.hi.states;

import java.util.ArrayList;
import java.util.List;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;

import com.drakulo.hi.gfx.splash.GameLoading;
import com.drakulo.hi.gfx.splash.SplashScreen;

/**
 * The splash screen shown when lunching the game
 */
public class SplashState extends BasicGameState {
	private List<SplashScreen> splashes;

	@Override
	public int getID() {
		return 0;
	}

	@Override
	public void init(GameContainer container, StateBasedGame game) throws SlickException {
		this.splashes = new ArrayList<SplashScreen>();
		this.splashes.add(new GameLoading());
	}

	@Override
	public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException {
		if (this.splashes.size() != 0) {
			SplashScreen s = this.splashes.get(0);
			s.render(g);
		}
	}

	@Override
	public void update(GameContainer container, StateBasedGame game, int arg2) throws SlickException {
		if (this.splashes.size() != 0) {
			SplashScreen s = this.splashes.get(0);
			s.update(container.getInput(), game);
			if (s.isDone()) {
				this.splashes.remove(0);
			}
		} else {
			// Splashes are all done. Let's go to the main menu!
			// game.enterState(State.MAIN_MENU);

			// For developpement :
			game.enterState(0);

		}
	}
}
